#pragma once

#include "fxcc/core/graph/opengl3/Program.h"
#include "fxcc/core/graph/opengl3/ShaderFile.h"

namespace fxcc
{
    namespace graph
    {
        namespace opengl3
        {
            struct FXCC_API ComputeShader : public fxcc::graph::opengl3::Program
            {

                ComputeShader(const std::string &sourceCode) : m_SourceCode(sourceCode), Program() {};
                std::string m_SourceCode;

                bool Init()
                {
                    ShaderFile cFile;

                    FXCC_FAILED(cFile.CreateFrom(m_SourceCode.c_str(), GL_COMPUTE_SHADER));
                    glAttachShader(this->m_Id, cFile.m_Id);

                    glLinkProgram(m_Id);
                }
                void MemoryBarrier()
                {
#ifdef WIN32
                    glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
#endif
                }
                void DispatchCompute(int x, int y, int z)
                {
#ifdef WIN32
                    glDispatchCompute(x, y, z);
#endif
                }
            };
        };
    };
};